package com.jzoffer2;


import ds.TreeNode;

/**
 * TODO
 *
 * @author lefly
 * @version 1.0
 * @classname No27
 * @description
 * @date 2021/2/1 下午1:03
 */
public class No27 {
    public static void main(String[] args) {
        TreeNode root = new TreeNode(1);
        TreeNode t1 = new TreeNode(12);
        TreeNode t2 = new TreeNode(13);
        TreeNode t3 = new TreeNode(2);
        TreeNode t4 = new TreeNode(3);
        root.left = t1;
        t1.right = t2;
        root.right = t3;
        t3.left = t4;

        TreeNode res = mirrorTree(root);
        System.out.println(res.left.val);
        System.out.println(res.right.val);
    }

    public static TreeNode mirrorTree(TreeNode root) {
        if(root == null){
            return root;
        }
        TreeNode leftNode = root.left;
        root.left = mirrorTree(root.right);
        root.right = mirrorTree(leftNode);

        return root;
    }

}
